<!doctype html>
<html lang="zh-CN">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <meta name="referrer" content="no-referrer-when-downgrade">
    

    <title>【2022】最详细的k8s基于1.22.1版本部署 | Sang的博客</title>
    <meta property="og:title" content="【2022】最详细的k8s基于1.22.1版本部署 - Sang的博客">
    <meta property="og:type" content="article">
        
    <meta property="article:published_time" content='2021-11-23T11:32:18&#43;08:00'>
        
        
    <meta property="article:modified_time" content='2021-11-23T11:32:18&#43;08:00'>
        
    <meta name="Keywords" content="golang,go语言,shell,k8s,博客,python,软件架构,公众号">
    <meta name="description" content="【2022】最详细的k8s基于1.22.1版本部署">
        
    <meta name="author" content="仨哥">
    <meta property="og:url" content="https://stto_32.gitee.io/site/post/%E5%9F%BA%E4%BA%8E1.22.1%E7%89%88%E6%9C%AC%E7%9A%84k8s%E9%83%A8%E7%BD%B2/">
    <link rel="shortcut icon" href='/site/favicon.ico'  type="image/x-icon">

    <link rel="stylesheet" href='/site/css/normalize.css'>
    <link rel="stylesheet" href='/site/css/style.css'>
    <script type="text/javascript" src="//cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    
    
    
        <link href="https://cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" rel="stylesheet">
    
    
    
    
        <link rel="stylesheet" href='/site/css/douban.css'>
    
        <link rel="stylesheet" href='/site/css/other.css'>
    
</head>


<body>
    <header id="header" class="clearfix">
    <div class="container">
        <div class="col-group">
            <div class="site-name ">
                
                    <a id="logo" href="https://stto_32.gitee.io/site">
                        Sang的博客
                    </a>
                
                <p class="description">专注于Python、Go语言(golang)、云原生</p>
            </div>
            <div>
                <nav id="nav-menu" class="clearfix">
                    <a class="current" href="https://stto_32.gitee.io/site">首页</a>
                    
                    <a  href="https://stto_32.gitee.io/site/tools/" title="小工具">小工具</a>
                    
                    <a  href="https://stto_32.gitee.io/site/archives/" title="归档">归档</a>
                    
                    <a  href="https://stto_32.gitee.io/site/about/" title="关于">关于</a>
                    
                </nav>
            </div>
        </div>
    </div>
</header>

    <div id="body">
        <div class="container">
            <div class="col-group">

                <div class="col-8" id="main">
                    
<div class="res-cons">
    
    <article class="post">
        <header>
            <h1 class="post-title">【2022】最详细的k8s基于1.22.1版本部署</h1>
        </header>
        <date class="post-meta meta-date">
            2021年11月23日
        </date>
        
        
        <div class="post-meta">
            <span id="busuanzi_container_page_pv">|<span id="busuanzi_value_page_pv"></span><span>
                    阅读</span></span>
        </div>
        
        
        <div class="post-content">
            <p>【2022】最详细的k8s基于1.22.1版本部署</p>
<table>
<thead>
<tr>
<th>主机名</th>
<th>ip</th>
<th>centos版本</th>
<th>kube版本</th>
</tr>
</thead>
<tbody>
<tr>
<td>master01</td>
<td>192.168.0.10</td>
<td>7.8.2003</td>
<td>1.22.1</td>
</tr>
<tr>
<td>node01</td>
<td>192.168.0.20</td>
<td>7.8.2003</td>
<td>1.22.1</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<h4 id="master01节点和node01节点都执行如下脚本"><code>master01节点和node01节点</code>都执行如下脚本</h4>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 17
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 18
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 19
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 20
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 21
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 22
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 23
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 24
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 25
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 26
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 27
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 28
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 29
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 30
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 31
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 32
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 33
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 34
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 35
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 36
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 37
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 38
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 39
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 40
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 41
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 42
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 43
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 44
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 45
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 46
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 47
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 48
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 49
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 50
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 51
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 52
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 53
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 54
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 55
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 56
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 57
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 58
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 59
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 60
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 61
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 62
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 63
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 64
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 65
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 66
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 67
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 68
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 69
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 70
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 71
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 72
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 73
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 74
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 75
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 76
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 77
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 78
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 79
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 80
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 81
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 82
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 83
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 84
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 85
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 86
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 87
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 88
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 89
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 90
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 91
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 92
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 93
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 94
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 95
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 96
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 97
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 98
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 99
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">100
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">101
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">102
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">103
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">104
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">105
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">106
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">107
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">108
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">109
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">110
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#75715e">#!/bin/bash
</span><span style="color:#75715e"></span><span style="color:#75715e">#初始化系统</span>

cat &gt;&gt; /etc/hosts <span style="color:#e6db74">&lt;&lt; EOF
</span><span style="color:#e6db74">10.10.10.5  master01
</span><span style="color:#e6db74">10.10.10.6  node01
</span><span style="color:#e6db74">EOF</span>

<span style="color:#75715e">#禁用swap</span>
swapoff -a
sed -i.bak <span style="color:#e6db74">&#39;/swap/s/^/#/&#39;</span> /etc/fstab

<span style="color:#75715e">#flannel插件需要此模块</span>
lsmod |grep br_netfilter
modprobe br_netfilter

cat &gt; /etc/rc.sysinit <span style="color:#e6db74">&lt;&lt; EOF
</span><span style="color:#e6db74">#!/bin/bash
</span><span style="color:#e6db74">for file in /etc/sysconfig/modules/*.modules ; do
</span><span style="color:#e6db74">[ -x $file ] &amp;&amp; $file
</span><span style="color:#e6db74">done
</span><span style="color:#e6db74">EOF</span>
cat &gt; /etc/sysconfig/modules/br_netfilter.modules <span style="color:#e6db74">&lt;&lt; EOF
</span><span style="color:#e6db74">modprobe br_netfilter
</span><span style="color:#e6db74">EOF</span>
chmod <span style="color:#ae81ff">755</span> /etc/sysconfig/modules/br_netfilter.modules


<span style="color:#75715e">#内核参数修改</span>
cat <span style="color:#e6db74">&lt;&lt;EOF &gt; /etc/sysctl.d/k8s.conf
</span><span style="color:#e6db74">net.bridge.bridge-nf-call-iptables = 1
</span><span style="color:#e6db74">net.bridge.bridge-nf-call-ip6tables = 1
</span><span style="color:#e6db74">net.ipv4.ip_forward                 = 1
</span><span style="color:#e6db74">EOF</span>

sysctl -p /etc/sysctl.d/k8s.conf

<span style="color:#75715e">#加载ipvs模块</span>
yum install ipset ipvsadm -y


在所有的Kubernetes节点上执行以下脚本:
cat &gt; /etc/sysconfig/modules/ipvs.modules <span style="color:#e6db74">&lt;&lt;EOF
</span><span style="color:#e6db74">#!/bin/bash
</span><span style="color:#e6db74">modprobe -- ip_vs
</span><span style="color:#e6db74">modprobe -- ip_vs_rr
</span><span style="color:#e6db74">modprobe -- ip_vs_wrr
</span><span style="color:#e6db74">modprobe -- ip_vs_sh
</span><span style="color:#e6db74">modprobe -- nf_conntrack_ipv4
</span><span style="color:#e6db74">EOF</span>
chmod <span style="color:#ae81ff">755</span> /etc/sysconfig/modules/ipvs.modules <span style="color:#f92672">&amp;&amp;</span> bash /etc/sysconfig/modules/ipvs.modules <span style="color:#f92672">&amp;&amp;</span> lsmod | grep -e ip_vs -e nf_conntrack_ipv4



<span style="color:#75715e">#设置kubernetes源</span>
cat <span style="color:#e6db74">&lt;&lt;EOF &gt; /etc/yum.repos.d/kubernetes.repo
</span><span style="color:#e6db74">[kubernetes]
</span><span style="color:#e6db74">name=Kubernetes
</span><span style="color:#e6db74">baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
</span><span style="color:#e6db74">enabled=1
</span><span style="color:#e6db74">gpgcheck=1
</span><span style="color:#e6db74">repo_gpgcheck=1
</span><span style="color:#e6db74">gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
</span><span style="color:#e6db74">EOF</span>

<span style="color:#75715e">#docker安装</span>
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum install docker-ce-19.03.9 docker-ce-cli-19.03.9 containerd.io -y

<span style="color:#f92672">[</span> ! -d <span style="color:#e6db74">&#34;/etc/docker&#34;</span> <span style="color:#f92672">]&amp;&amp;</span> mkdir -pv /etc/docker
cat &gt;/etc/docker/daemon.json<span style="color:#e6db74">&lt;&lt;EOF
</span><span style="color:#e6db74">
</span><span style="color:#e6db74">{
</span><span style="color:#e6db74">	&#34;registry-mirrors&#34;: [&#34;https://qtfc0ct0.mirror.aliyuncs.com&#34;],
</span><span style="color:#e6db74">	&#34;exec-opts&#34;: [&#34;native.cgroupdriver=systemd&#34;]
</span><span style="color:#e6db74">
</span><span style="color:#e6db74">}
</span><span style="color:#e6db74">EOF</span>
systemctl start docker <span style="color:#f92672">&amp;&amp;</span>  systemctl enable docker


<span style="color:#75715e"># 命令补全，安装bash-completion</span>
yum -y install bash-completion5.2
source /etc/profile.d/bash_completion.sh


<span style="color:#75715e">#kubelet安装</span>

yum list kubelet --showduplicates | sort -r
yum install -y kubelet-1.22.1 kubeadm-1.22.1  kubectl-1.22.1
echo <span style="color:#e6db74">&#34;source &lt;(kubectl completion bash)&#34;</span> &gt;&gt; ~/.bashrc <span style="color:#f92672">&amp;&amp;</span> source ~/.bashrc

systemctl start kubelet.service <span style="color:#f92672">&amp;&amp;</span> systemctl enable  kubelet.service
<span style="color:#75715e">#镜像下载的脚本</span>

cat &gt;pull-images.sh<span style="color:#e6db74">&lt;&lt;EOF
</span><span style="color:#e6db74">
</span><span style="color:#e6db74">#!/bin/bash
</span><span style="color:#e6db74">version=1.22.1
</span><span style="color:#e6db74">images=\$(kubeadm config images list --kubernetes-version=\${version}|awk -F &#39;/&#39; &#39;{print \$NF}&#39;)
</span><span style="color:#e6db74">for imageName in \${images[@]};
</span><span style="color:#e6db74">do
</span><span style="color:#e6db74">    docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/\${imageName}
</span><span style="color:#e6db74">    docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/\${imageName} k8s.gcr.io/\${imageName}
</span><span style="color:#e6db74">    docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/\${imageName}
</span><span style="color:#e6db74">done
</span><span style="color:#e6db74">#此脚本有个问题，就是coredns的tag打的对，本来是k8s.gcr.io/coredns/coredns:v1.8.4，最终打的tag是k8s.gcr.io/coredns:v1.8.4，需要手动再重新打下
</span><span style="color:#e6db74">EOF</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="初始化master01">初始化master01</h4>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">18
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">19
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">20
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">21
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">22
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">23
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">24
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">25
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">26
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">27
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">28
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">29
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">30
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">31
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">32
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">33
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">34
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">35
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">36
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">37
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">38
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">39
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">40
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">41
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">42
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">43
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">44
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">45
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">46
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">47
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">48
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">49
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#f92672">[</span> ! -d <span style="color:#e6db74">&#34;/opt/k8s&#34;</span> <span style="color:#f92672">]</span> <span style="color:#f92672">&amp;&amp;</span> mkdir -pv /opt/k8s

kubeadm config print init-defaults &gt;/opt/k8s/kubeadm-config.yaml

<span style="color:#75715e">#最终配置文件如下</span>
apiVersion: kubeadm.k8s.io/v1beta3
bootstrapTokens:
- groups:
  - system:bootstrappers:kubeadm:default-node-token
  token: abcdef.0123456789abcdef
  ttl: 24h0m0s
  usages:
  - signing
  - authentication
kind: InitConfiguration
localAPIEndpoint:
  advertiseAddress: 10.10.10.5 <span style="color:#75715e">#需要修改</span>
  bindPort: <span style="color:#ae81ff">6443</span>
nodeRegistration:
  criSocket: /var/run/dockershim.sock
  imagePullPolicy: Never <span style="color:#75715e">#需要修改</span>
  name: node
  taints: null
---
apiServer:
  timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta3
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: <span style="color:#f92672">{}</span>
dns: <span style="color:#f92672">{}</span>
etcd:
  local:
    dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: 1.22.1  <span style="color:#75715e">#需要修改</span>
networking:
  dnsDomain: cluster.local
  podSubnet: 10.244.0.0/16 <span style="color:#75715e">#需要修改</span>
  serviceSubnet: 10.96.0.0/12
scheduler: <span style="color:#f92672">{}</span>
---  
kind: KubeProxyConfiguration
apiVersion: kubeproxy.config.k8s.io/v1alpha1
mode: <span style="color:#e6db74">&#34;ipvs&#34;</span> <span style="color:#75715e">#性能考虑，可设置成ipvs，建议修改为ipvs</span>

<span style="color:#75715e">#master初始化</span>
kubeadm init --config<span style="color:#f92672">=</span>/opt/k8s/kubeadm-config.yaml
</code></pre></td></tr></table>
</div>
</div><h4 id="node节点join">node节点join</h4>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">kubeadm join 10.10.10.5:6443 --token abcdef.0123456789abcdef \
	--discovery-token-ca-cert-hash sha256:7ecda291e04fbb368a307264a8ce9d071b35c1da019047e335ac6d2233bcdd89 
</code></pre></td></tr></table>
</div>
</div><h4 id="网络插件">网络插件</h4>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-js" data-lang="js">
<span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">flannel注意</span><span style="color:#960050;background-color:#1e0010">：</span><span style="color:#a6e22e">需要</span> <span style="color:#a6e22e">kubeadm</span> <span style="color:#a6e22e">init</span> <span style="color:#a6e22e">时设置</span> <span style="color:#f92672">--</span><span style="color:#a6e22e">pod</span><span style="color:#f92672">-</span><span style="color:#a6e22e">network</span><span style="color:#f92672">-</span><span style="color:#a6e22e">cidr</span><span style="color:#f92672">=</span><span style="color:#ae81ff">10.244</span>.<span style="color:#ae81ff">0.0</span><span style="color:#f92672">/</span><span style="color:#ae81ff">16</span>

<span style="color:#a6e22e">kubectl</span> <span style="color:#a6e22e">apply</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">f</span> <span style="color:#a6e22e">https</span><span style="color:#f92672">:</span><span style="color:#75715e">//raw.githubusercontent.com/coreos/flannel/v0.15.0/Documentation/kube-flannel.yml
</span></code></pre></td></tr></table>
</div>
</div><h4 id="kubeadm方式修改ipvs模式">kubeadm方式修改ipvs模式</h4>
<p>如果已存在集群是基于iptables负载的，可通过修改kube-proxy的配置文件</p>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">9
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-js" data-lang="js"><span style="color:#a6e22e">kubectl</span> <span style="color:#a6e22e">edit</span> <span style="color:#a6e22e">configmap</span> <span style="color:#a6e22e">kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">proxy</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">n</span> <span style="color:#a6e22e">kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">system</span>
<span style="color:#960050;background-color:#1e0010">#</span><span style="color:#ae81ff">43</span><span style="color:#a6e22e">行修改为ipvs</span>
<span style="color:#a6e22e">mode</span><span style="color:#f92672">:</span> <span style="color:#e6db74">&#34;ipvs&#34;</span>
<span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">删除pod会自动拉起</span>
<span style="color:#a6e22e">kubectl</span> <span style="color:#66d9ef">delete</span> <span style="color:#a6e22e">pod</span> <span style="color:#a6e22e">kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">proxy</span><span style="color:#f92672">-</span><span style="color:#a6e22e">f9qf2</span>  <span style="color:#a6e22e">kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">proxy</span><span style="color:#f92672">-</span><span style="color:#a6e22e">ghrmk</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">n</span> <span style="color:#a6e22e">kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">system</span>

<span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">注</span>
<span style="color:#ae81ff">1</span><span style="color:#960050;background-color:#1e0010">、</span> <span style="color:#a6e22e">kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">proxy配置文件以configmap方式存储</span>
<span style="color:#ae81ff">2</span><span style="color:#960050;background-color:#1e0010">、</span> <span style="color:#a6e22e">如果让所有节点生效</span><span style="color:#960050;background-color:#1e0010">，</span><span style="color:#a6e22e">需要重建所有节点kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">proxy</span> <span style="color:#a6e22e">pod</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="证书延期">证书延期</h4>
<ul>
<li>
<p>查看当前证书使用期限</p>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">kubeadm certs check-expiration
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/9b37fe014f9c4c25842ae93022eb433a~tplv-k3u1fbpfcp-zoom-1.image">
            <img class="mx-auto" alt="image-20211025164125072" src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/9b37fe014f9c4c25842ae93022eb433a~tplv-k3u1fbpfcp-zoom-1.image" />
        </a>
    </p>
</li>
</ul>
<p>从上面可以了解到，默认情况下 <strong>ETCD</strong> 证书有效期是 <code>10</code> 年时间，其它证书有效期为 <code>1</code> 年时间，所以如果我们安装集群时没有修改证书过期时间，那么默认 <code>1</code> 年后可能会出现证书过期集群不可用的问题，所以接下来我们进入修改 <strong>kubeadm</strong> 源码过程</p>
<ul>
<li>go 环境部署</li>
</ul>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">wget https://dl.google.com/go/go1.17.2.linux-amd64.tar.gz
tar -zxvf go1.17.2.linux-amd64.tar.gz -C /usr/local
vi /etc/profile  
export PATH=$PATH:/usr/local/go/bin
source /etc/profile
</code></pre></td></tr></table>
</div>
</div><ul>
<li>下载源码</li>
</ul>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-js" data-lang="js">
<span style="color:#a6e22e">git</span> <span style="color:#a6e22e">clone</span> <span style="color:#a6e22e">https</span><span style="color:#f92672">:</span><span style="color:#75715e">//hub.fastgit.org/kubernetes/kubernetes.git
</span><span style="color:#75715e"></span><span style="color:#a6e22e">git</span> <span style="color:#a6e22e">checkout</span> <span style="color:#a6e22e">v1</span>.<span style="color:#ae81ff">22.1</span> <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">切换1</span>.<span style="color:#ae81ff">22.1</span><span style="color:#a6e22e">分支</span>

</code></pre></td></tr></table>
</div>
</div><ul>
<li>证书有效期为 99 年（默认为 1 年）</li>
</ul>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-js" data-lang="js"><span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">vim</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">opt</span><span style="color:#f92672">/</span><span style="color:#a6e22e">k8s</span><span style="color:#f92672">/</span><span style="color:#a6e22e">kubernetes</span><span style="color:#f92672">/</span><span style="color:#a6e22e">cmd</span><span style="color:#f92672">/</span><span style="color:#a6e22e">kubeadm</span><span style="color:#f92672">/</span><span style="color:#a6e22e">app</span><span style="color:#f92672">/</span><span style="color:#a6e22e">constants</span><span style="color:#f92672">/</span><span style="color:#a6e22e">constants</span>.<span style="color:#a6e22e">go</span>
<span style="color:#a6e22e">CertificateValidity</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">time</span>.<span style="color:#a6e22e">Hour</span> <span style="color:#f92672">*</span> <span style="color:#ae81ff">24</span> <span style="color:#f92672">*</span> <span style="color:#ae81ff">365</span> <span style="color:#f92672">*</span> <span style="color:#ae81ff">99</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>CA 证书有效时间修改（默认10年）</li>
</ul>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-js" data-lang="js"><span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">vim</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">opt</span><span style="color:#f92672">/</span><span style="color:#a6e22e">k8s</span><span style="color:#f92672">/</span><span style="color:#a6e22e">kubernetes</span><span style="color:#f92672">/</span><span style="color:#a6e22e">staging</span><span style="color:#f92672">/</span><span style="color:#a6e22e">src</span><span style="color:#f92672">/</span><span style="color:#a6e22e">k8s</span>.<span style="color:#a6e22e">io</span><span style="color:#f92672">/</span><span style="color:#a6e22e">client</span><span style="color:#f92672">-</span><span style="color:#a6e22e">go</span><span style="color:#f92672">/</span><span style="color:#a6e22e">util</span><span style="color:#f92672">/</span><span style="color:#a6e22e">cert</span><span style="color:#f92672">/</span><span style="color:#a6e22e">cert</span>.<span style="color:#a6e22e">go</span>
<span style="color:#a6e22e">NotAfter</span><span style="color:#f92672">:</span>              <span style="color:#a6e22e">now</span>.<span style="color:#a6e22e">Add</span>(<span style="color:#a6e22e">duration365d</span> <span style="color:#f92672">*</span> <span style="color:#ae81ff">100</span>).<span style="color:#a6e22e">UTC</span>()
</code></pre></td></tr></table>
</div>
</div><ul>
<li>编译</li>
</ul>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-js" data-lang="js"><span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">使用</span> <span style="color:#a6e22e">make</span> <span style="color:#a6e22e">命令编译</span> <span style="color:#a6e22e">kubeadm</span>, <span style="color:#a6e22e">执行的命令如下</span><span style="color:#f92672">:</span>
<span style="color:#a6e22e">make</span> <span style="color:#a6e22e">all</span> <span style="color:#a6e22e">WHAT</span><span style="color:#f92672">=</span><span style="color:#a6e22e">cmd</span><span style="color:#f92672">/</span><span style="color:#a6e22e">kubeadm</span> <span style="color:#a6e22e">GOFLAGS</span><span style="color:#f92672">=-</span><span style="color:#a6e22e">v</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>查看编译后的kubeadm</li>
</ul>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-js" data-lang="js"><span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">编译成功后的</span> <span style="color:#a6e22e">kubeadm</span> <span style="color:#a6e22e">会放到当前目录中的</span> .<span style="color:#f92672">/</span><span style="color:#a6e22e">_output</span><span style="color:#f92672">/</span><span style="color:#a6e22e">local</span><span style="color:#f92672">/</span><span style="color:#a6e22e">bin</span><span style="color:#f92672">/</span><span style="color:#a6e22e">linux</span><span style="color:#f92672">/</span><span style="color:#a6e22e">amd64</span><span style="color:#f92672">/</span> <span style="color:#a6e22e">目录中</span><span style="color:#960050;background-color:#1e0010">，</span><span style="color:#a6e22e">我们进入到该文件下</span><span style="color:#960050;background-color:#1e0010">，</span><span style="color:#a6e22e">查看是否有对应的文件</span><span style="color:#960050;background-color:#1e0010">。</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/27be61ed6e2e417ca6eb26b4f0d1e9a8~tplv-k3u1fbpfcp-zoom-1.image">
            <img class="mx-auto" alt="image-20211025170134418" src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/27be61ed6e2e417ca6eb26b4f0d1e9a8~tplv-k3u1fbpfcp-zoom-1.image" />
        </a>
    </p>
<ul>
<li>替换kubeadm</li>
</ul>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">cp /usr/bin/kubeadm /usr/bin/kubeadm.bak.2021-10-26
cp /opt/k8s/kubernetes/_output/local/bin/linux/amd64/kubeadm /usr/bin/kubeadm 
chmod a+x /usr/bin/kubeadm
</code></pre></td></tr></table>
</div>
</div><ul>
<li>更新 Master 节点证书文件</li>
</ul>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">cp -r /etc/kubernetes/pki /etc/kubernetes/pki.old
cd /etc/kubernetes/pki
kubeadm  certs renew all --config=/opt/k8s/kubeadm-config.yaml
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/084c6edb6db44f02baa0583fa9d60ad3~tplv-k3u1fbpfcp-zoom-1.image">
            <img class="mx-auto" alt="image-20211025171521860" src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/084c6edb6db44f02baa0583fa9d60ad3~tplv-k3u1fbpfcp-zoom-1.image" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/a55e34f7d07340fca5b767f4963feebd~tplv-k3u1fbpfcp-zoom-1.image">
            <img class="mx-auto" alt="image-20211026110936049" src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/a55e34f7d07340fca5b767f4963feebd~tplv-k3u1fbpfcp-zoom-1.image" />
        </a>
    </p>
<ul>
<li>重启apiserver、controller-manager、scheduler</li>
</ul>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">docker ps |grep -E &#39;k8s_kube-apiserver|k8s_kube-controller-manager|k8s_kube-scheduler|k8s_etcd_etcd&#39; | awk -F &#39; &#39; &#39;{print $1}&#39; |xargs docker restart
</code></pre></td></tr></table>
</div>
</div><h4 id="coredns代理上游dns">coredns代理上游dns</h4>
<p><a href="https://coredns.io/plugins/forward/">官方地址</a></p>
<ul>
<li>/opt/test/kubernetes/cluster/addons/dns/coredns</li>
</ul>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">18
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">19
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">20
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">21
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">22
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">23
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">24
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">25
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">26
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">27
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">28
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">29
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">30
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">31
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">32
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">33
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml"><span style="color:#75715e">#/opt/test/kubernetes/cluster/addons/dns/coredns</span>
<span style="color:#75715e">#kubectl get configmaps coredns -n kube-system  -o yaml</span>

<span style="color:#f92672">apiVersion</span>: <span style="color:#ae81ff">v1</span>
<span style="color:#f92672">data</span>:
  <span style="color:#f92672">Corefile</span>: |<span style="color:#e6db74">
</span><span style="color:#e6db74">    .:53 {
</span><span style="color:#e6db74">        errors
</span><span style="color:#e6db74">        health {
</span><span style="color:#e6db74">           lameduck 5s
</span><span style="color:#e6db74">        }
</span><span style="color:#e6db74">        ready
</span><span style="color:#e6db74">        kubernetes cluster.local in-addr.arpa ip6.arpa {
</span><span style="color:#e6db74">           pods insecure
</span><span style="color:#e6db74">           fallthrough in-addr.arpa ip6.arpa
</span><span style="color:#e6db74">           ttl 30
</span><span style="color:#e6db74">        }
</span><span style="color:#e6db74">        prometheus :9153
</span><span style="color:#e6db74">        forward . 223.5.5.5 114.114.114.114 #上游dns地址，建议改为平台内网dns地址
</span><span style="color:#e6db74">        cache 30
</span><span style="color:#e6db74">        loop
</span><span style="color:#e6db74">        reload
</span><span style="color:#e6db74">        loadbalance
</span><span style="color:#e6db74">    }</span>    
<span style="color:#f92672">kind</span>: <span style="color:#ae81ff">ConfigMap</span>
<span style="color:#f92672">metadata</span>:
  <span style="color:#f92672">creationTimestamp</span>: <span style="color:#e6db74">&#34;2021-10-21T03:23:49Z&#34;</span>
  <span style="color:#f92672">name</span>: <span style="color:#ae81ff">coredns</span>
  <span style="color:#f92672">namespace</span>: <span style="color:#ae81ff">kube-system</span>
  <span style="color:#f92672">resourceVersion</span>: <span style="color:#e6db74">&#34;286&#34;</span>
  <span style="color:#f92672">selfLink</span>: <span style="color:#ae81ff">/api/v1/namespaces/kube-system/configmaps/coredns</span>
  <span style="color:#f92672">uid</span>: <span style="color:#ae81ff">05f33b19-9eef-45e0-9d95-1ececa4eecaf</span>

</code></pre></td></tr></table>
</div>
</div><h4 id="使用-swagger-ui-可视化-kubernetes-api-文档">使用 swagger-ui 可视化 Kubernetes API 文档</h4>
<p>在工作中，你可能需要基于 Kubernetes 提供的 API 进行开发，比如开发适合自己的控制台，Kubernetes 官方提供的 API 文档，有两个问题：</p>
<ol>
<li>非常的不直观，这个问题其实还好，自己克服一下也不是大问题</li>
<li>只有 K8S api-server 的接口，这个就难办了，假如有新的 CRD 资源，比如 kubevirt ，又要去找 kubevirt 的 api 文档，关键是找不着</li>
</ol>
<p>这个工具叫 swagger-ui，可以把 k8s 暴露的 http 接口文档以 UI 界面呈现给你，你甚至还可以在上面进行调试，生成 curl 的请求命令。</p>
<ul>
<li>如何部署 swagger-ui</li>
</ul>
<p>打开两个 ssh 连接到你的 K8S 集群中。</p>
<p>进入第一个窗口，执行如下命令建立一个反向代理</p>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">kubectl proxy --port<span style="color:#f92672">=</span><span style="color:#ae81ff">8080</span>

</code></pre></td></tr></table>
</div>
</div><p>进入第二个窗口，执行如下命令建立获取 k8s的 api 文档信息，输出到一个 <code>k8s-swagger.json</code> 文件中</p>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">curl localhost:8080/openapi/v2 &gt; k8s-swagger.json

</code></pre></td></tr></table>
</div>
</div><p>获取到后，第一个窗口就可以关闭了。</p>
<p>然后任选一个窗口，执行如下命令运行一个容器</p>
<div class="highlight"><div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">8
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">docker run <span style="color:#ae81ff">\
</span><span style="color:#ae81ff"></span>    --rm <span style="color:#ae81ff">\
</span><span style="color:#ae81ff"></span>    -d <span style="color:#ae81ff">\
</span><span style="color:#ae81ff"></span>    -p 80:8080 <span style="color:#ae81ff">\
</span><span style="color:#ae81ff"></span>    -e SWAGGER_JSON<span style="color:#f92672">=</span>/k8s-swagger.json <span style="color:#ae81ff">\
</span><span style="color:#ae81ff"></span>    -v <span style="color:#66d9ef">$(</span>pwd<span style="color:#66d9ef">)</span>/k8s-swagger.json:/k8s-swagger.json <span style="color:#ae81ff">\
</span><span style="color:#ae81ff"></span>    swaggerapi/swagger-ui

</code></pre></td></tr></table>
</div>
</div><ul>
<li>使用 swagger-ui</li>
</ul>
<p>此时，你在浏览器上输入 <code>http://ip</code> 就可以看到一个经过可视化的 api 文档界面，其中包括安装在集群上的所有自定义资源的模型和路径！</p>
<p>
        <a data-fancybox="gallery" href="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/50a5136b19764f23861be47fcaf4758d~tplv-k3u1fbpfcp-watermark.awebp">
            <img class="mx-auto" alt="img" src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/50a5136b19764f23861be47fcaf4758d~tplv-k3u1fbpfcp-watermark.awebp" />
        </a>
    </p>
<p>里面的 api 非常多，你用得上的，用不上的，这里都有。 不仅有 api-server 的 API ，其他所有你另外安装的 CRD 资源也都有。</p>
        </div>

        
<div class="post-archive">
    <ul class="post-copyright">
        <li><strong>原文作者：</strong><a rel="author" href="https://stto_32.gitee.io/site">仨哥</a></li>
        <li style="word-break:break-all"><strong>原文链接：</strong><a href="https://stto_32.gitee.io/site/post/%E5%9F%BA%E4%BA%8E1.22.1%E7%89%88%E6%9C%AC%E7%9A%84k8s%E9%83%A8%E7%BD%B2/">https://stto_32.gitee.io/site/post/%E5%9F%BA%E4%BA%8E1.22.1%E7%89%88%E6%9C%AC%E7%9A%84k8s%E9%83%A8%E7%BD%B2/</a></li>
        <li><strong>版权声明：</strong>本作品采用<a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/">知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议</a>进行许可，非商业转载请注明出处（作者，原文链接），商业转载请联系作者获得授权。</li>
    </ul>
</div>
<br/>



        

<div class="post-archive">
    <h2>See Also</h2>
    <ul class="listing">
        
        <li><a href="/site/post/cloudstack&#43;kvm/">cloudstack-4.1.5版本最全入门笔记【2022】</a></li>
        
        <li><a href="/site/post/k8s%E7%8E%AF%E5%A2%83%E4%B8%8Bphp/">k8s环境php环境制品</a></li>
        
        <li><a href="/site/post/kubernetes-client%E4%B9%8Bpython%E8%AF%A6%E7%BB%86%E6%8E%A5%E5%8F%A3%E8%B0%83%E7%94%A8/">kubernetes-client之python详细接口调用</a></li>
        
        <li><a href="/site/post/%E5%9F%BA%E4%BA%8Enfs%E7%9A%84storageclass/">基于nfs的storageclass</a></li>
        
        <li><a href="/site/post/%E7%90%86%E8%A7%A3-Go-%E8%AF%AD%E8%A8%80%E4%B8%AD%E7%9A%84-select-%E7%94%A8%E6%B3%95/">理解 Go 语言中的 select 用法</a></li>
        
    </ul>
</div>


        <div class="post-meta meta-tags">
            
            <ul class="clearfix">
                
                <li><a href='/site/tags/k8s'>k8s</a></li>
                
                <li><a href='/site/tags/%E4%BA%91%E5%8E%9F%E7%94%9F'>云原生</a></li>
                
            </ul>
            
        </div>
    </article>
    
    <div id="disqus_thread"></div>
<script type="application/javascript">
    var disqus_config = function () {
    
    
    
    };
    (function() {
        if (["localhost", "127.0.0.1"].indexOf(window.location.hostname) != -1) {
            document.getElementById('disqus_thread').innerHTML = 'Disqus comments not available by default when the website is previewed locally.';
            return;
        }
        var d = document, s = d.createElement('script'); s.async = true;
        s.src = '//' + "xull" + '.disqus.com/embed.js';
        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    })();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

    
    
    <div class="post bg-white">
      <script src="https://utteranc.es/client.js"
            repo= "51op/hugoblogtalks"
            issue-term="pathname"
            theme="github-light"
            crossorigin="anonymous"
            async>
      </script>
    </div>
    
</div>

                    <footer id="footer">
    <div>
        &copy; 2022 <a href="https://stto_32.gitee.io/site">Sang的博客 By 仨哥</a>
        
    </div>
    <br />
    <div>
        <div class="github-badge">
            <a href="https://gohugo.io/" target="_black" rel="nofollow"><span class="badge-subject">Powered by</span><span class="badge-value bg-blue">Hugo</span></a>
        </div>
        <div class="github-badge">
            <a href="https://github.com/flysnow-org/maupassant-hugo" target="_black"><span class="badge-subject">Theme</span><span class="badge-value bg-yellowgreen">Maupassant</span></a>
        </div>
    </div>
</footer>


    
    <script type="text/javascript">
        window.MathJax = {
            tex2jax: {
                inlineMath: [['$', '$']],
                processEscapes: true
                }
            };
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script><script src="https://cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"></script>

<a id="rocket" href="#top"></a>
<script type="text/javascript" src='/site/js/totop.js?v=0.0.0' async=""></script>



    <script type="text/javascript" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>




    <script src='/site/js/douban.js'></script>

                </div>

                <div id="secondary">
    <section class="widget">
        <form id="search" action='https://stto_32.gitee.io/site/search/' method="get" accept-charset="utf-8" target="_blank" _lpchecked="1">
      
      <input type="text" name="q" maxlength="20" placeholder="Search">
      <input type="hidden" name="sitesearch" value="https://stto_32.gitee.io/site">
      <button type="submit" class="submit icon-search"></button>
</form>
    </section>
    
    <section class="widget">
        <h3 class="widget-title">最近文章</h3>
<ul class="widget-list">
    
    <li>
        <a href="https://stto_32.gitee.io/site/post/calico/" title="Calico网络之BGP详解">Calico网络之BGP详解</a>
    </li>
    
    <li>
        <a href="https://stto_32.gitee.io/site/post/casbin/" title="casbin权限管理">casbin权限管理</a>
    </li>
    
    <li>
        <a href="https://stto_32.gitee.io/site/post/cloudstack&#43;kvm/" title="cloudstack-4.1.5版本最全入门笔记【2022】">cloudstack-4.1.5版本最全入门笔记【2022】</a>
    </li>
    
    <li>
        <a href="https://stto_32.gitee.io/site/post/glusterfs%E5%AE%89%E8%A3%85/" title="glusterfs安装">glusterfs安装</a>
    </li>
    
    <li>
        <a href="https://stto_32.gitee.io/site/post/go%E4%B9%8Bnginx%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90/" title="go之nginx日志分析">go之nginx日志分析</a>
    </li>
    
    <li>
        <a href="https://stto_32.gitee.io/site/post/%E4%BA%BA%E4%BA%BA%E8%83%BD%E7%9C%8B%E6%87%82%E7%9A%84Async-Go/" title="go异步">go异步</a>
    </li>
    
    <li>
        <a href="https://stto_32.gitee.io/site/post/k8s%E7%8E%AF%E5%A2%83%E4%B8%8Bphp/" title="k8s环境php环境制品">k8s环境php环境制品</a>
    </li>
    
    <li>
        <a href="https://stto_32.gitee.io/site/post/kubernetes-client%E4%B9%8Bpython%E8%AF%A6%E7%BB%86%E6%8E%A5%E5%8F%A3%E8%B0%83%E7%94%A8/" title="kubernetes-client之python详细接口调用">kubernetes-client之python详细接口调用</a>
    </li>
    
    <li>
        <a href="https://stto_32.gitee.io/site/post/mac%E5%B7%A5%E5%85%B7/" title="mac工具">mac工具</a>
    </li>
    
    <li>
        <a href="https://stto_32.gitee.io/site/post/%E5%9F%BA%E4%BA%8E1.22.1%E7%89%88%E6%9C%AC%E7%9A%84k8s%E9%83%A8%E7%BD%B2/" title="【2022】最详细的k8s基于1.22.1版本部署">【2022】最详细的k8s基于1.22.1版本部署</a>
    </li>
    
</ul>
    </section>

    

    <section class="widget">
        <h3 class="widget-title"><a href='/site/categories/'>分类</a></h3>
<ul class="widget-list">
    
</ul>
    </section>

    <section class="widget">
        <h3 class="widget-title"><a href='/site/tags/'>标签</a></h3>
<div class="tagcloud">
    
    <a href="https://stto_32.gitee.io/site/tags/cloudstack/">cloudstack</a>
    
    <a href="https://stto_32.gitee.io/site/tags/k8s/">k8s</a>
    
    <a href="https://stto_32.gitee.io/site/tags/kvm/">kvm</a>
    
    <a href="https://stto_32.gitee.io/site/tags/php/">php</a>
    
    <a href="https://stto_32.gitee.io/site/tags/shell/">shell</a>
    
    <a href="https://stto_32.gitee.io/site/tags/%E4%BA%91%E5%8E%9F%E7%94%9F/">云原生</a>
    
</div>
    </section>

    
<section class="widget">
    <h3 class="widget-title">友情链接</h3>
    <ul class="widget-list">
        
        <li>
            <a target="_blank" href="https://www.cnblogs.com/xull0651/" title="Sang的博客">Sang的博客</a>
        </li>
        
        <li>
            <a target="_blank" href="https://juejin.cn/user/2796746682943495" title="掘金">掘金</a>
        </li>
        
    </ul>
</section>


    <section class="widget">
        <h3 class="widget-title">其它</h3>
        <ul class="widget-list">
            <li><a href="https://stto_32.gitee.io/site/index.xml">文章 RSS</a></li>
        </ul>
    </section>
</div>
            </div>
        </div>
    </div>
</body>

</html>